package com.freesky.web.manager.controller.search;

import com.freesky.common.dao.entity.SearchExpandLexcion;
import com.freesky.common.pojo.DataTablesResult;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.web.manager.remote.search.ExpandLexiconRemote;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author Freesky
 */
@Controller
@Api(description = "拓展词库管理")
@RequestMapping("/search/expand-lexicon")
public class ExpandLexiconController {

    @Autowired
    private ExpandLexiconRemote expandLexiconRemote;

    @GetMapping(value = "/page")
    @ApiOperation(value = "进入界面-拓展词库列表")
    public String page() {
        return "search/expand-lexicon/list";
    }

    @GetMapping(value = "/add/page")
    @ApiOperation(value = "进入界面-拓展词库添加")
    public String addPage() {
        return "search/expand-lexicon/add";
    }

    @ApiOperation(value = "获得扩展词库列表")
    @ResponseBody
    @GetMapping(value = "/list")
    public DataTablesResult getList() {
        return expandLexiconRemote.getList();
    }

    @ApiOperation(value = "添加扩展词库")
    @ResponseBody
    @PostMapping(value = "/add")
    public JSONResponse add(@ModelAttribute SearchExpandLexcion searchExpandLexcion) {
        return expandLexiconRemote.add(searchExpandLexcion);
    }

    @ApiOperation(value = "删除扩展词库")
    @ResponseBody
    @DeleteMapping(value = "/del/{ids}")
    public JSONResponse deleteById(@PathVariable(value = "ids") Integer[] ids) {
        return expandLexiconRemote.deleteById(ids);
    }
}
